package org.example.Controller;

import jakarta.annotation.Resource;
import org.example.common.Result;
import org.example.pojo.Category;
import org.example.pojo.Query;
import org.example.service.CategoryService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("Category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;
    @PostMapping("/list")
    public Result getlist(@RequestBody Query query){
        Result result= categoryService.getlist(query);
        return result;
    }
    @PostMapping("/add")
    public Result add(@RequestBody Category category){
        Result result=categoryService.add(category);
        return result;
    }
    @PostMapping("/update")
    public Result update(@RequestBody Category category){
        Result result=categoryService.updatecate(category);
        return result;
    }
    @PostMapping("/delete")
    public Result delete(Integer id){
        Result result=categoryService.deletebyid(id);
        return result;
    }
    @PostMapping("/selectById")
    public Result selectById(Integer id){
        Result result=categoryService.selectById(id);
        return result;
    }
}
